﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;

namespace CKNetFrameWork
{
    class ClassUltraGridCommonSet
    {
        public static void InitUltraWinGridSetting(Infragistics.Win.UltraWinGrid.UltraGrid ultraGrid1)
        {
            ultraGrid1.DisplayLayout.Override.RowSelectors = Infragistics.Win.DefaultableBoolean.True;
            ultraGrid1.DisplayLayout.Override.RowSelectorNumberStyle = Infragistics.Win.UltraWinGrid.RowSelectorNumberStyle.VisibleIndex;
            ultraGrid1.DisplayLayout.Override.RowSelectorWidth = 30;
        }

        public static void InitUltraWinGridRowNumSetting(Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
        {
            e.Layout.Override.RowSelectors = Infragistics.Win.DefaultableBoolean.True;
            e.Layout.Override.RowSelectorNumberStyle = Infragistics.Win.UltraWinGrid.RowSelectorNumberStyle.VisibleIndex;
        }

        public static void LocalPrintPreveiw()
        {
            //Infragistics.Shared.ResourceCustomizer rc = Infragistics.Win.Printing.Resources.Customizer;//Resources.Customizer;
            //rc.SetCustomizedString("PrintPreview_DialogCaption", "打印预览");
            //rc.SetCustomizedString("PrintPreview_Tool_Print", "打印(&P)");
            //rc.SetCustomizedString("PrintPreview_Tool_ClosePreview", "关闭(&C)");
            //rc.SetCustomizedString("PrintPreview_Tool_ContextMenuPreviewZoom", "显示比例");
            //rc.SetCustomizedString("PrintPreview_Tool_Current_Page", "当前页");
            //rc.SetCustomizedString("PrintPreview_Tool_Exit", "退出(&X)");
            //rc.SetCustomizedString("PrintPreview_Tool_First_Page", "第一页");
            //rc.SetCustomizedString("PrintPreview_Tool_Go_To", "跳至");
            //rc.SetCustomizedString("PrintPreview_Tool_Last_Page", "最后一页");
            //rc.SetCustomizedString("PrintPreview_Tool_Next_Page", "下一页");
            //rc.SetCustomizedString("PrintPreview_Tool_Previous_Page", "前一页");
            //rc.SetCustomizedString("PrintPreview_Tool_Next_View", "下一视图(&N)");
            //rc.SetCustomizedString("PrintPreview_Tool_Previous_View", "前一视图(&P)");
            //rc.SetCustomizedString("PrintPreview_Tool_Hand_Tool", "手型工具(&H)");
            //rc.SetCustomizedString("PrintPreview_Tool_Page_Setup", "页面设置(&U)");
            //rc.SetCustomizedString("PrintPreview_Tool_Snapshot_Tool", "快照工具(&S)");
            //rc.SetCustomizedString("PrintPreview_Tool_View", "视图(&V)");
            //rc.SetCustomizedString("PrintPreview_Tool_Whole_Page", "合适页");
            //rc.SetCustomizedString("PrintPreview_Tool_Zoom", "缩放(&Z)");
            //rc.SetCustomizedString("PrintPreview_Tool_Zoom_In", "放大");

            //rc.SetCustomizedString("PrintPreview_Tool_Zoom_Out", "缩小");

            //rc.SetCustomizedString("PrintPreview_ToolCategory_Context_Menus", "上下文菜单");
            //rc.SetCustomizedString("PrintPreview_ToolCategory_File", "文件");
            //rc.SetCustomizedString("PrintPreview_ToolCategory_Menus", "菜单");
            //rc.SetCustomizedString("PrintPreview_ToolCategory_Tools", "工具栏");
            //rc.SetCustomizedString("PrintPreview_ToolCategory_View", "视图");
            //rc.SetCustomizedString("PrintPreview_ToolCategory_Zoom_Mode", "缩放模式");

            //rc.SetCustomizedString("PrintPreview_ToolTip_ClosePreview", "关闭");
            //rc.SetCustomizedString("PrintPreview_ToolTip_Zoom", "缩放");
            //rc.SetCustomizedString("StatusBar_Page_X_OF_X", "页:{0}/{1}");

            //rc.SetCustomizedString("CustomizeImg_ToolBar_MenuBar", "菜单");
            //rc.SetCustomizedString("CustomizeImg_ToolBar_Standard", "标准");
            //rc.SetCustomizedString("CustomizeImg_ToolBar_View", "视图");
            //rc.SetCustomizedString("PrintPreview_Tool_File", "文件(&F)");
            //rc.SetCustomizedString("PrintPreview_Tool_Tools", "工具(&T)");
            //rc.SetCustomizedString("PrintPreview_Tool_Dynamic_Zoom_Tool", "动态缩放工具(&D)");
            //rc.SetCustomizedString("PrintPreview_Tool_Zoom_Out_Tool", "缩小工具");
            //rc.SetCustomizedString("PrintPreview_Tool_Zoom_In_Tool", "放大工具");
            //// rc.SetCustomizedString("PrintPreview_Tool_Page_Layout","菜单");
            //rc.SetCustomizedString("PreviewRowColSelection_Cancel", "取消");
            //rc.SetCustomizedString("PreviewRowColSelection_SelectedPages", "{0} x {1} 页");

            //rc.SetCustomizedString("PreviewRowColSelection_Cancel", "取消");
            //rc.SetCustomizedString("PrintPreview_Tool_Page_Width", "页宽");
            //rc.SetCustomizedString("PrintPreview_ZoomListItem_MarginWidth", "文字宽度");
            //rc.SetCustomizedString("PrintPreview_ZoomListItem_PageWidth", "页宽");
            //rc.SetCustomizedString("PrintPreview_ZoomListItem_WholePage", "合适页");
            //rc.SetCustomizedString("PrintPreview_Tool_Page_Layout", "页面布局");
            //rc.SetCustomizedString("PrintPreview_Tool_Margin_Width", "文字宽度");
            //rc.SetCustomizedString("ContextMenuPreviewHand", "缩放视图");


            //rc.SetCustomizedString("PrintPreview_Tool_Reduce_Page_Thumbnails", "缩小");
            //rc.SetCustomizedString("PrintPreview_Tool_Show_Page_Numbers", "显示页号");
            //rc.SetCustomizedString("PrintPreview_Tool_ContextMenuThumbnail", "缩略图");
            //rc.SetCustomizedString("PrintPreview_Tool_Enlarge_Page_Thumbnails", "放大");
            //rc.SetCustomizedString("PrintPreview_Tool_Thumbnails", "缩略图");
            //rc.SetCustomizedString("PrintPreview_Tool_Continuous", "连续排序");
            ////说明
            //rc.SetCustomizedString("StatusBar_DynamicZoom_Instructions", "单击并拖动进行缩放操作");
            //rc.SetCustomizedString("StatusBar_Page_X_OF_X", "当前页: {0} / {1}");
            //rc.SetCustomizedString("StatusBar_SnapShot_Instructions", "单击并拖动,系统将选定矩型区域复制到剪帖板");
            //rc.SetCustomizedString("StatusBar_ZoomIn_Instructions", "单击并拖动,系统将放大选定矩型区域");
            //rc.SetCustomizedString("StatusBar_ZoomOut_Instructions", "单击并拖动,系统将缩小选定矩型区域");
            //rc.SetCustomizedString("StatusBar_Hand_Instructions", "单击并拖动以便显示更多内容");

            ////Infragistics.Shared.ResourceCustomizer rc2 = Infragistics.Win.UltraWinGrid.Resources.Customizer;//Resources.Customizer;

            ////rc2.SetCustomizedString("Does not contain", "不包含");



            ////Infragistics.Shared.ResourceCustomizer rc2 = Infragistics.Win.UltraWinGrid.Resources.Customizer;
            ////rc2.SetCustomizedString("RowFilterDropDownAllItem", "所有");
            ////rc2.SetCustomizedString("RowFilterDropDownBlanksItem", "空");
            ////rc2.SetCustomizedString("RowFilterDropDownCustomItem", "自定义");
            ////rc2.SetCustomizedString("RowFilterDropDownNonBlanksItem", "非空");
            ////rc2.SetCustomizedString("RowFilterDropDownAllItem", "所有");
            ////rc2.SetCustomizedString("RowFilterDialogTitlePrefix", "输入过滤准则为");
            ////rc2.SetCustomizedString("FilterDialogAndRadioText", "并且");
            ////rc2.SetCustomizedString("FilterDialogOrRadioText", "或者");
            ////rc2.SetCustomizedString("FilterDialogAddConditionButtonText", "增加一个条件(&N)");
            ////rc2.SetCustomizedString("FilterDialogDeleteButtonText", "删除一个条件");
            ////rc2.SetCustomizedString("FilterDialogOkButtonText", "确定(&O)");
            ////rc2.SetCustomizedString("FilterDialogCancelButtonText", "取消(&C)");
            ////rc2.SetCustomizedString("FilterDialogOkButtonNoFiltersText", "不过滤");
            ////rc2.SetCustomizedString("RowFilterDialogOperatorHeaderCaption", "比较运算符");
            ////rc2.SetCustomizedString("RowFilterDialogOperandHeaderCaption", "准则");
            ////rc2.SetCustomizedString("RowFilterDropDownEquals", "等于");
            ////rc2.SetCustomizedString("RowFilterDropDownNotEquals", "不等于");
            ////rc2.SetCustomizedString("RowFilterDropDownLessThan", "小于");
            ////rc2.SetCustomizedString("RowFilterDropDownLessThanOrEqualTo", "小于等于");
            ////rc2.SetCustomizedString("RowFilterDropDownGreaterThan", "大于");
            ////rc2.SetCustomizedString("RowFilterDropDownGreaterThanOrEqualTo", "大于等于");
            ////rc2.SetCustomizedString("RowFilterDropDownMatch", "自定义规则表达式");
            ////rc2.SetCustomizedString("RowFilterDropDownLike", "模糊查找");

            ////rc2.SetCustomizedString("RowFilterDialogBlanksItem", "空白");
            ////rc2.SetCustomizedString("RowFilterDialogDBNullItem", "无值");
            ////rc2.SetCustomizedString("RowFilterDialogEmptyTextItem", "空字符");

            ////rc2.SetCustomizedString("RowFilterDropDown_Operator_Equals", "等于");
            ////rc2.SetCustomizedString("RowFilterDropDown_Operator_NotEquals", "不等于");
            ////rc2.SetCustomizedString("RowFilterDropDown_Operator_LessThan", "小于");
            ////rc2.SetCustomizedString("RowFilterDropDown_Operator_LessThanOrEqualTo", "小于等于");
            ////rc2.SetCustomizedString("RowFilterDropDown_Operator_GreaterThan", "大于");
            ////rc2.SetCustomizedString("RowFilterDropDown_Operator_GreaterThanOrEqualTo", "大于等于");
            ////rc2.SetCustomizedString("RowFilterDropDown_Operator_Match", "自定义规则表达式");
            ////rc2.SetCustomizedString("RowFilterDropDown_Operator_Like", "模糊查找");

            ////rc2.SetCustomizedString("RowFilterPatternCaption", "无效查找模式");
            ////rc2.SetCustomizedString("RowFilterPatternError", "错误的解析模式{0}. 请输入一个有效的表达式");
            ////rc2.SetCustomizedString("RowFilterPatternException", "无效查找模式{0}");
            ////rc2.SetCustomizedString("RowFilterRegexError", "无效的规则表达式{0}.请输入一个有效的表达式");
            ////rc2.SetCustomizedString("RowFilterRegexErrorCaption", "无效规则表达式");
            ////rc2.SetCustomizedString("RowFilterRegexException", "无效规则表达式{0}");
        }

        public static void SetSumColumn(Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e, List<string> lstSumColumnName)
        {
            SummarySettings averageSummary;
            foreach (string str in lstSumColumnName)
            {
                averageSummary =
e.Layout.Bands[0].Summaries.Add(
str,
SummaryType.Sum,
e.Layout.Bands[0].Columns[str]);
                averageSummary.SummaryPosition = SummaryPosition.UseSummaryPositionColumn;
                averageSummary.SummaryPositionColumn = averageSummary.SourceColumn;
                averageSummary.DisplayFormat = "{0:.##}";
                averageSummary.Band.Override.SummaryFooterCaptionVisible = DefaultableBoolean.False;
                averageSummary.Band.Override.BorderStyleSummaryFooter = UIElementBorderStyle.None;
                averageSummary.SummaryDisplayArea = SummaryDisplayAreas.TopFixed;
            }

        }
        public static void ultraGrid1_InitializeRowFilter(Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
        {
            //ultraGrid1.DisplayLayout.Override.RowSizing = RowSizing.AutoFree;
            //foreach (UltraGridColumn ugc in ultraGrid1.DisplayLayout.Bands[0].Columns)
            //    ugc.PerformAutoResize();
            // FILTER ROW FUNCTIONALITY RELATED ULTRAGRID SETTINGS
            //e.Layout.Override.RowFilterAction = RowFilterAction.DisableFilteredOutRows;
            // ----------------------------------------------------------------------------------
            // Enable the the filter row user interface by setting the FilterUIType to FilterRow.
            e.Layout.Override.FilterUIType = FilterUIType.FilterRow;
            //e.Layout.Override.RowFilterMode = RowFilterMode.AllRowsInBand;
            // FilterEvaluationTrigger specifies when UltraGrid applies the filter criteria typed 
            // into a filter row. Default is OnCellValueChange which will cause the UltraGrid to
            // re-filter the data as soon as the user modifies the value of a filter cell.
            e.Layout.Override.FilterEvaluationTrigger = FilterEvaluationTrigger.OnCellValueChange;
            //e.Layout.Override.RowFilterMode = RowFilterMode.AllRowsInBand;
            // By default the UltraGrid selects the type of the filter operand editor based on
            // the column's DataType. For DateTime and boolean columns it uses the column's editors.
            // For other column types it uses the Combo. You can explicitly specify the operand
            // editor style by setting the FilterOperandStyle on the override or the individual
            // columns.
            e.Layout.Override.FilterOperandStyle = FilterOperandStyle.Edit;

            // By default UltraGrid displays user interface for selecting the filter operator. 
            // You can set the FilterOperatorLocation to hide this user interface. This
            // property is available on column as well so it can be controlled on a per column
            // basis. Default is WithOperand. This property is exposed off the column as well.
            e.Layout.Override.FilterOperatorLocation = FilterOperatorLocation.WithOperand;

            // By default the UltraGrid uses StartsWith as the filter operator. You use
            // the FilterOperatorDefaultValue property to specify a different filter operator
            // to use. This is the default or the initial filter operator value of the cells
            // in filter row. If filter operator user interface is enabled (FilterOperatorLocation
            // is not set to None) then that ui will be initialized to the value of this
            // property. The user can then change the operator as he/she chooses via the operator
            // drop down.
            e.Layout.Override.FilterOperatorDefaultValue = FilterOperatorDefaultValue.Contains;

            // FilterOperatorDropDownItems property can be used to control the options provided
            // to the user for selecting the filter operator. By default UltraGrid bases 
            // what operator options to provide on the column's data type. This property is
            // avaibale on the column as well.
            //e.Layout.Override.FilterOperatorDropDownItems = FilterOperatorDropDownItems.All;

            // By default UltraGrid displays a clear button in each cell of the filter row
            // as well as in the row selector of the filter row. When the user clicks this
            // button the associated filter criteria is cleared. You can use the 
            // FilterClearButtonLocation property to control if and where the filter clear
            // buttons are displayed.
            e.Layout.Override.FilterClearButtonLocation = FilterClearButtonLocation.RowAndCell;
            
            // Appearance of the filter row can be controlled using the FilterRowAppearance proeprty.
            e.Layout.Override.FilterRowAppearance.BackColor = Color.LightYellow;

            // You can use the FilterRowPrompt to display a prompt in the filter row. By default
            // UltraGrid does not display any prompt in the filter row.
            e.Layout.Override.FilterRowPrompt = "Click here to filter data...";

            // You can use the FilterRowPromptAppearance to change the appearance of the prompt.
            // By default the prompt is transparent and uses the same fore color as the filter row.
            // You can make it non-transparent by setting the appearance' BackColorAlpha property 
            // or by setting the BackColor to a desired value.
            e.Layout.Override.FilterRowPromptAppearance.BackColorAlpha = Alpha.Opaque;
    
            // By default the prompt is spread across multiple cells if it's bigger than the
            // first cell. You can confine the prompt to a particular cell by setting the
            // SpecialRowPromptField property off the band to the key of a column.
            //e.Layout.Bands[0].SpecialRowPromptField = e.Layout.Bands[0].Columns[0].Key;

            // Display a separator between the filter row other rows. SpecialRowSeparator property 
            // can be used to display separators between various 'special' rows, including for the
            // filter row. This property is a flagged enum property so it can take multiple values.
            e.Layout.Override.SpecialRowSeparator = SpecialRowSeparator.FilterRow;

            // You can control the appearance of the separator using the SpecialRowSeparatorAppearance
            // property.
            e.Layout.Override.SpecialRowSeparatorAppearance.BackColor = Color.FromArgb(233, 242, 199);

         //   UltraGridBand band = e.Layout.Bands[0];
         //   band.ColumnFilters["原币金额"].FilterConditions.Clear();
         //   band.ColumnFilters["原币金额"].FilterConditions.Add(

         //FilterComparisionOperator.GreaterThan, 5);
         //   band.ColumnFilters["原币金额"].FilterConditions.Add(
            
         //FilterComparisionOperator.LessThan, 10);
         //   band.ColumnFilters["原币金额"].LogicalOperator = FilterLogicalOperator.And;
        }

    }
}
